// 引入request
import request from 'utils/request'
// 定义 请求 分类接口
const fetchCates = (params = {}) => request.get('/shop/goods/category/all', { params })
// 轮播接口
const fetchSwipe = (params = {}) => request.get('/banner/list', { params })
// 首页列表接口
const fetchItem = (params = {}) => request.post('/shop/goods/list/v2', params)
// 商品详情
const fetchDetail = (id) => request.get('/shop/goods/detail', {
  params: {
    id
  }
})
// 用户注册
const register = (params = {}) => request.post('/user/username/register', params)
// 用户登录
const login = (params = {}) => request.post('/user/username/login', params)
// 购物车数据
const fetchCartItems = (params = {}) => request.get('/shopping-cart/info', { params })
// 加入购物车
const addCart = (params = {}) => request.post('/shopping-cart/add', params)
// 添加购物车数量
const addNum = (params = {}) => request.post('/shopping-cart/modifyNumber', params)
// 复选框状态
const changeChecked = (params = {}) => request.post('/shopping-cart/select', params)
// 购物车删除记录
const deleteCart = (params = {}) => request.post('/shopping-cart/remove', params)
// 新增收货联系人
const addContact = (params = {}) => request.post('/user/shipping-address/add', params)
// 收货人列表
const fetchContact = (params = {}) => request.post('/user/shipping-address/list/v2', params)
// 修改收货地址
const editContact = (params = {}) => request.post('/user/shipping-address/update', params)
// 获取收货地址详情
const getContact = (params = {}) => request.get('/user/shipping-address/detail/v2', { params })
// 删除联系人收货地址
const deleteContact = (params = {}) => request.post('/user/shipping-address/delete', params)
// 获取默认联系
const defaultContact = (params = {}) => request.get('/user/shipping-address/default/v2', { params })

export {
  fetchCates,
  fetchSwipe,
  fetchItem,
  fetchDetail,
  register,
  login,
  fetchCartItems,
  addCart,
  addNum,
  changeChecked,
  deleteCart,
  addContact,
  fetchContact,
  editContact,
  getContact,
  deleteContact,
  defaultContact
}
